package com.ruoyi.web.controller.teaching;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.PlatformLLearn;
import com.ruoyi.teaching.service.PlatformLLearnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 王旭
 * @since 2024-07-05
 */
@RestController
@RequestMapping("/platform/learn")
@Api(tags = "platform-学习记录管理")
public class PlatformLLearnController {
    @Autowired
    private PlatformLLearnService platformLLearnService;

    /**
     * 查询个人学习记录列表
     */
//    @PreAuthorize("@ss.hasPermi('platform:learn:listOwn')")
    @GetMapping("/listOwn")
    @ApiOperation(value = "查询个人学习记录列表", notes = "查询个人学习记录列表")
    public AjaxResult listOwn(Integer pageNum, Integer pageSize, Integer learnType, Integer choose) {
        return platformLLearnService.listOwn(pageNum, pageSize, learnType, choose);
    }

    /**
     * 获取某个课程/虚拟仿真的学习记录
     */
    @GetMapping("/getLearn")
    @ApiOperation(value = "获取某个课程/虚拟仿真的学习记录", notes = "获取某个课程/虚拟仿真的学习记录")
    public AjaxResult getLearn(Integer projectId,Integer learnType) {
        return platformLLearnService.getLearnByProjectId(projectId,learnType);
    }

    /**
     * 新增个人学习记录
     */
//    @PreAuthorize("@ss.hasPermi('platform:learn:edit')")
    @Log(title = "【新增个人学习记录】", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "新增个人学习记录", notes = "新增个人学习记录")
    public AjaxResult edit(@RequestBody PlatformLLearn platformLLearn) {
        return platformLLearnService.insertPlatformLLearn(platformLLearn);
    }

    /**
     * 删除个人学习记录
     */
//    @PreAuthorize("@ss.hasPermi('platform:learn:remove')")
    @Log(title = "【删除个人学习记录】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除个人学习记录", notes = "删除个人学习记录")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return platformLLearnService.deletelearnByIds(ids);
    }


}

